package me.sealer.java8.methodreference;

import me.sealer.java8.actparamterized.enumeration.Color;
import me.sealer.java8.actparamterized.model.Apple;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * Created by sealer on 09-17-2017.
 */
public class Constructor {
    public static void main(String[] args) {
        Supplier<String> supplier;
        String s;
        Apple apple;
        BiFunction<Color, Double, Apple> biFunction;

//        supplier = () -> new String();
        supplier = String::new;//与上等价

        s = supplier.get();
        System.out.println(s);


        //带一个参数的构造函数
        Function<String, String> function;

//        function = ss -> new String(ss);
        function = String::new;//与上等价
        s = function.apply("function string");
        System.out.println(s);


        //带两个参数的构造函数
//        biFunction = (t, d) -> new Apple(t, d);
        biFunction = Apple::new;//与上等价
        apple = biFunction.apply(Color.GREEN, 120.0);
        System.out.println(apple);

    }
}
